package dp.gr03.payroll.payrollDomain;

import java.util.GregorianCalendar;

import dp.gr03.payroll.Paycheck;
import dp.gr03.payroll.affiliations.NoAffiliation;

public class Employee
{
    protected PaymentMethod paymentMethod;
    protected PaymentClassification paymentClassification;
    protected Affiliation affiliation;
    protected PaymentSchedule paymentSchedule;

    protected int id;
    protected String name;
    protected String address;

    public Employee(int employeeId, String employeeName, String employeeAddress)
    {
        this.id = employeeId;
        this.name = employeeName;
        this.address = employeeAddress;
        this.affiliation = new NoAffiliation();
    }

    public boolean isPayDay(GregorianCalendar date)
    {
        return paymentSchedule.isPayDate(date);
    }

    public double calculatePay(Paycheck payCheck)
    {
        return paymentClassification.calculatePay(payCheck);
    }

    public String getName()
    {
        return name;
    }

    public PaymentMethod getPaymentMethod()
    {
        return paymentMethod;
    }

    public void setPaymentMethod(PaymentMethod paymentMethod)
    {
        this.paymentMethod = paymentMethod;
    }

    public PaymentClassification getPaymentClassification()
    {
        return paymentClassification;
    }

    public void setPaymentClassification(PaymentClassification paymentClassification)
    {
        this.paymentClassification = paymentClassification;
    }

    public PaymentSchedule getPaymentSchedule()
    {
        return paymentSchedule;
    }

    public void setPaymentSchedule(PaymentSchedule paymentSchedule)
    {
        this.paymentSchedule = paymentSchedule;
    }

    public int getId()
    {
        return id;
    }

    public void setId(int id)
    {
        this.id = id;
    }

    public String getAddress()
    {
        return address;
    }

    public void setAddress(String address)
    {
        this.address = address;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public Affiliation getAffiliation()
    {
        return affiliation;
    }

    public void setAffiliation(Affiliation affiliation)
    {
        this.affiliation = affiliation;
    }

    public void payDay(Paycheck pc)
    {
        double grossPay = getPaymentClassification().calculatePay(pc);
        double deductions = getAffiliation().calculatePay(pc);
        double netPay = grossPay - deductions;
        pc.setGrossPay(grossPay);
        pc.setDeductions(deductions);
        pc.setNetPay(netPay);
        getPaymentMethod().pay(pc);
    }

    public GregorianCalendar getPayPeriodStartDate(GregorianCalendar payDate)
    {
        return getPaymentSchedule().getPayPeriodStartDate(payDate);
    }
}